package com.itliang.security.handler;

import com.itliang.core.result.ResponseUtil;
import com.itliang.core.result.ResultUtils;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.web.AuthenticationEntryPoint;
import org.springframework.stereotype.Component;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 认证异常处理器
 *
 * @author : liangzhuoyuan
 * @createDate : 2023-03-22 23:54
 */
@Component
public class AuthenticationEntryPointHandler implements AuthenticationEntryPoint {
    @Override
    public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException) throws IOException, ServletException {

        ResponseUtil.out(response, ResultUtils.error(433, "AuthenticationEntryPointHandler"));

    }
}
